package com.jiyun.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiyun.model.Exam;
import com.jiyun.model.PaperGame;
import com.jiyun.service.ExamService;
import com.jiyun.service.PaperGameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author 朱庆辉
 * @Date 2023/7/28 16:05
 * @Email 1018276870@qq.com
 */
@RestController
@RequestMapping("paperGame")
public class PaperGameController {
    @Autowired
    private PaperGameService paperGameService;

    @Autowired
    private ExamService examService;
    @RequestMapping("findAllExamId")
    private  List<PaperGame> findAllExamId(Integer id){
        QueryWrapper<PaperGame> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("paper_id",id);
        List<PaperGame> list1 = paperGameService.list(queryWrapper);
        List<Exam> list = examService.list();
        for (PaperGame paperGame : list1) {
            for (Exam exam : list) {
                if (paperGame.getAnswer()!=null){
                    if (paperGame.getExamId().equals(exam.getId())){
                        if(paperGame.getAnswer().equals(exam.getAnswer())){
                            paperGame.setJudge(1);
                        }
                    }
                }
            }
        }
        return list1;
    }
}
